// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   key_register_ok.java

package logistics.config.key;

import include.nseer_db.nseer_db_backup1;
import include.query.getRecordCount;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class key_register_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;
	nseer_db_backup1 erp_db;

	public key_register_ok()
	{
		erp_db = null;
	}

	public synchronized void doPost(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			java.io.PrintWriter out = response.getWriter();
			nseer_db_backup1 security_db = new nseer_db_backup1(dbApplication);
			if (security_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				getRecordCount query = new getRecordCount();
				String tablename = request.getParameter("tablename");
				String cols[] = request.getParameterValues("col");
				if (cols == null)
				{
					response.sendRedirect("logistics/config/key/key_register_ok_a.jsp");
				} else
				{
					String column_group = "";
					for (int i = 0; i < cols.length; i++)
						column_group = (new StringBuilder(String.valueOf(column_group))).append(cols[i]).append(",").toString();

					column_group = column_group.substring(0, column_group.length() - 1);
					String sql1 = (new StringBuilder("select * from security_publicconfig_key where tablename='")).append(tablename).append("'").toString();
					ResultSet rs = security_db.executeQuery(sql1);
					if (rs.next())
					{
						String sql = (new StringBuilder("update security_publicconfig_key set column_group='")).append(column_group).append("' where tablename='").append(tablename).append("'").toString();
						security_db.executeUpdate(sql);
					} else
					{
						String sql = (new StringBuilder("insert into security_publicconfig_key(tablename,column_group) values('")).append(tablename).append("','").append(column_group).append("')").toString();
						security_db.executeUpdate(sql);
					}
					response.sendRedirect("logistics/config/key/key_register_ok_b.jsp");
				}
				security_db.commit();
				security_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
